/**
 * form提交
 * @name formSend
 * @param {*} url
 * @param {*} paramsObj
 */
export function formSend(url, paramsObj = {}, method = 'post') {
  return new Promise(reslove => {
    const form = document.createElement('form');
    const formProps = {
      acceptCharset: 'utf-8',
      method,
      action: url,
      target: 'export_iframe',
      name: 'export_form',
    };
    for (let [name, value] of Object.entries(formProps)) {
      form[name] = value;
    }
    // 带上身份信息
    paramsObj = { ...paramsObj};
    for (let [name, value] of Object.entries(paramsObj)) {
      const input = document.createElement('input');
      input.name = name;
      input.value = value;
      input.type = 'hidden';
      form.appendChild(input);
    }
    document.body.append(form);
    form.submit();
    setTimeout(() => {
      document.body.removeChild(form);
      reslove(true);
    }, 10);
  });
}
